package cn.jobstart.es.search;

import cn.jobstart.es.model.AbstractEsModel;
import org.dromara.easyes.common.params.SFunction;
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
import org.dromara.easyes.core.toolkit.FieldUtils;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

/**
 * @author sunke
 * @version 1.0
 * @Description
 * @date 2023-09-27 17:15
 */
public abstract class AbstractEsSearch<T extends AbstractEsModel, S extends LambdaEsQueryWrapper<T>> extends LambdaEsQueryWrapper<T> {


    private int pageNumber;
    private int pageSize;

    public int getPageNumber() {
        return pageNumber;
    }

    public S setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
        return getThis();
    }

    public int getPageSize() {
        return pageSize;
    }

    public S setPageSize(int pageSize) {
        this.pageSize = pageSize;
        return getThis();
    }

    public abstract S getThis();

/*
    @Override
    public S like(SFunction<T, ?> column, Object val) {
        return likeField(FieldUtils.getFieldName(column), val);

    }*/

/*    public S likeField(String field, Object value) {

        QueryBuilder queryBuilder = QueryBuilders.queryStringQuery("(" + field + ".keyword:*" + value + "*)");
        this.mix(queryBuilder);
        return getThis();

    }*/

}
